#include "nvicconfig.h"
#include "stm32f4xx.h"

/*****************************************************************************
*函  数：void NVIV_Config(void)
*功  能：配置工程中所有中断的优先级
*参  数：无
*返回值：无
*备  注：此优先级中断不要随便更改哦
*****************************************************************************/
void NVIV_Config(void)
{
  NVIC_InitTypeDef  NVIC_InitStructure;
	
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断分组2
	
	//PPM解码外部中断
  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority =1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure); 
	
	//HC_SR04超声波外部中断
	NVIC_InitStructure.NVIC_IRQChannel=EXTI3_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority =0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
	
	//程序时基TIM2定时器中断优先级
	NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢断优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //子优选级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
	
	//程序时基TIM4定时器中断优先级
	NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; //抢断优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //子优选级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
	
	//USART2中断
	NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢断优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;//子优选级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
	
	//USART1中断
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢断优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //子优选级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}
